﻿//
// Created by wzh on 2020/12/29.
//

#ifndef SPLINE_H
#define SPLINE_H

#include "abstractfitter.h"
#include "bandsolver.h"

//三次样条曲线拟合工具
class SplineFitter : public AbstractFitter {

public:
    //边界条件类型
    enum BoundValueType {
        First,
        Second,
        Third
    };
public:
    SplineFitter();

    //设置边界条件
    void setBoundary(BoundValueType type, double left = 0.0, double right = 0.0);

    //设置数据点并进行拟合
    bool setPoints(const Vecd &x, const Vecd &y) override;

    //计算给定点x的估计值
    double operator()(double x) override;


private:
    //系数： y = m_1*x + m_2*x^2 + m_3*x^3 + y_i
    Arrd m_1, m_2, m_3;
    //边界条件类型
    BoundValueType m_bound_type;
    //边界点一阶导数值
    double m_bound_l, m_bound_r;
};


#endif //SPLINE_H
